package ar.com.laley.centro.dao;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.classic.Session;
import org.hibernate.criterion.Expression;

import ar.com.laley.centro.beans.HibernateUtil;
import ar.com.laley.centro.beans.Materia;

public class AjaxDAOImpl implements AjaxDAO {

	public List obtenerMaterias() throws Exception {
		List result = new ArrayList();
		HibernateUtil.currentSession();
		Session session = (Session) HibernateUtil.currentSession();

		Criteria crit = session.createCriteria(Materia.class);
		result = crit.list();

		return result;
	}

	public List obtenerCatedras(int idMateria) throws Exception {
		List result = new ArrayList();
		HibernateUtil.currentSession();
		Session session = (Session) HibernateUtil.currentSession();

		Criteria crit = session.createCriteria(Materia.class);
		crit.add(Expression.eq("materiaId", new Integer(idMateria)));
		result = crit.list();

		return result;
	}
}
